import config from "@/config"
import http from "@/utils/request"


// 财务
export default {
  // 报销管理
  getReimbursementList: {
    url: `${config.API_URL}/reimbursement/list`,
    name: "获取报销列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addReimbursement: {
    url: `${config.API_URL}/reimbursement/add`,
    name: "添加报销",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updateReimbursement: {
    url: `${config.API_URL}/reimbursement/update`,
    name: "修改报销",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deleteReimbursement: {
    url: `${config.API_URL}/reimbursement/delete`,
    name: "删除报销",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getReimbursementCountMoney: {
    url: `${config.API_URL}/reimbursement/listStatistics`,
    name: "列表统计",
    get: function (data) {
      return new Promise((resolve, reject) => {
        http.get(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  confirmReimbursement: {
    url: `${config.API_URL}/reimbursement/payment`,
    name: "确认报销付款",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getReimbursementById: {
    url: `${config.API_URL}/reimbursement/listByReimburseId`,
    name: "根据id获取报销详情",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  // 收款管理-回款
  collectManagement: {
    getCollectList: {
      url: `${config.API_URL}/customerPayment/list`,
      name: "获取收款列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    addCollect: {
      url: `${config.API_URL}/customerPayment/add`,
      name: "添加收款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updateCollect: {
      url: `${config.API_URL}/customerPayment/update`,
      name: "修改收款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deleteCollect: {
      url: `${config.API_URL}/customerPayment/delete`,
      name: "删除收款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getCollectDetailById: {
      url: `${config.API_URL}/customerPayment/listByPaymentId`,
      name: "根据id获取收款详情",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getAuditMoney: {
      url: `${config.API_URL}/customerPayment/getMoney`,
      name: "根据计划id获取收款详情",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getCountMoney: {
      url: `${config.API_URL}/customerPayment/listStatistics`,
      name: "统计金额",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getMoneByCustomerId: {
      url: `${config.API_URL}/customerPayment/arrearsMoney`,
      name: "根据客户id获取欠费金额(客户列表)",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getNotCollectionList: {
      url: `${config.API_URL}/customerPayment/notCollectionList`,
      name: "未收款的客户列表",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getCustomerOrders: {
      url: `${config.API_URL}/customerPayment/customerOrders`,
      name: "获取客户源订单",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },

  // 计划回款-应收账款
  plancollect: {
    getPlancollectList: {
      url: `${config.API_URL}/plancollect/list`,
      name: "获取计划回款列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    // 获取有成交量的客户
    getCustomerNumbers: {
      url: `${config.API_URL}/customer/customerNumber`,
      name: "获取有成交量的客户",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    addPlancollect: {
      url: `${config.API_URL}/plancollect/add`,
      name: "添加计划回款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updatePlancollect: {
      url: `${config.API_URL}/plancollect/update`,
      name: "修改计划回款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deletePlancollect: {
      url: `${config.API_URL}/plancollect/delete`,
      name: "删除计划回款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    updatePlanCollectStatus: {
      url: `${config.API_URL}/plancollect/updateStatus`,
      name: "单笔回款接口",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    returnList: {
      url: `${config.API_URL}/customerPayment/planDetail`,
      name: "应收账款收款明细",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getCountMoney: {
      url: `${config.API_URL}/plancollect/listStatistics`,
      name: "统计金额",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    }
  },

  // 借款
  loanManagement: {
    getLoanList: {
      url: `${config.API_URL}/loan/list`,
      name: "获取借款列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    confirmLoan: {
      url: `${config.API_URL}/loan/payment`,
      name: "确认借款付款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    addLoan: {
      url: `${config.API_URL}/loan/add`,
      name: "添加借款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    updateLoan: {
      url: `${config.API_URL}/loan/update`,
      name: "修改借款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.post(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    deleteLoan: {
      url: `${config.API_URL}/loan/delete`,
      name: "删除借款",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },

    getLoanDetailById: {
      url: `${config.API_URL}/loan/listById`,
      name: "根据id获取借款详情",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getCountMoney: {
      url: `${config.API_URL}/loan/listStatistics`,
      name: "统计金额",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    }
  },

  // 单据类型
  expenseType: {
    getExpenseTypeList: {
      url: `${config.API_URL}/expenses/list`,
      name: "获取单据类型列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    addExpenseType: {
      url: `${config.API_URL}/expenses/add`,
      name: "添加单据类型",
      post: function (param) {
        return new Promise((resolve, reject) => {
          http.post(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    updateExpenseType: {
      url: `${config.API_URL}/expenses/update`,
      name: "修改单据类型",
      post: function (param) {
        return new Promise((resolve, reject) => {
          http.post(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    changeExpenseTypeState: {
      url: `${config.API_URL}/expenses/disableEnable`,
      name: "禁用/启用单据类型",
      post: function (param) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },

  // 对账单管理
  bill: {
    getBillList: {
      url: `${config.API_URL}/bill/list`,
      name: "获取账单列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    addBill: {
      url: `${config.API_URL}/bill/add`,
      name: "生产对账单",
      post: function (param) {
        return new Promise((resolve, reject) => {
          http.post(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getPlanListByCustomerId: {
      url: `${config.API_URL}/bill/planList`,
      name: "根据客户id获取对应应收账款列表",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    update: {
      url: `${config.API_URL}/bill/update`,
      name: "更新账单",
      post: function (param) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getBillDetail: {
      url: `${config.API_URL}/bill/detailOne`,
      name: "获取对账单详情",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    // /customerPayment/billGetMoney
    getBillCheckMoney: {
      url: `${config.API_URL}/customerPayment/billGetMoney`,
      name: "获取账单的在审金额",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    exportBillById: {
      url: `${config.API_URL}/bill/export`,
      name: "导出账单明细",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data, { responseType: 'blob' }).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    returnList: {
      url: `${config.API_URL}/customerPayment/customerDetail`,
      name: "对账单收款明细",
      get: function (data) {
        return new Promise((resolve, reject) => {
          http.get(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    getBillCount: {
      url: `${config.API_URL}/bill/statistics`,
      name: "账单统计",
      get: function (param) {
        return new Promise((resolve, reject) => {
          http.get(this.url, param).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
    joinBill: {
      url: `${config.API_URL}/bill/addBill`,
      name: "加入对账单",
      post: function (data) {
        return new Promise((resolve, reject) => {
          http.postParam(this.url, data).then((response) => {
            resolve(response)
          }).catch((error) => {
            resolve(error.data)
          })
        })
      }
    },
  },

  getFinanceCountData: {
    url: `${config.API_URL}/statistics/outcome`,
    name: "获取财务统计(支出)",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },


  getFinanceCountDataByYear: {
    url: `${config.API_URL}/statistics/financeStatistics`,
    name: "根据你那份获取财务统计",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getTotalMoney: {
    url: `${config.API_URL}/statistics/financeStatist`,
    name: "获取总额统计",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getProportionOfTotal: {
    url: `${config.API_URL}/statistics/totalPercentage`,
    name: "获取总额占比",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getProportionOfLoanType: {
    url: `${config.API_URL}/statistics/loanPercentage`,
    name: "获取借款类型占比",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getLoanCount: {
    url: `${config.API_URL}/statistics/loanStatistics`,
    name: "获取借款统计",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getReimburseCount: {
    url: `${config.API_URL}/statistics/reimburseStatistics`,
    name: "获取报销统计",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getProportionOfReimburseType: {
    url: `${config.API_URL}/statistics/reimbursePercentage`,
    name: "获取报销类型占比",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  getProportionOfPayment: {
    url: `${config.API_URL}/statistics/paymentTypePercentage`,
    name: "获取付款类型占比",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  getPaymentCount: {
    url: `${config.API_URL}/statistics/paymentStatistics`,
    name: "获取付款统计",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
}
